home *** CD-ROM | disk | FTP | other *** search
/ PC Format (UK) 104 / PC Format 2000 January - Disc 2.iso / SETUP.BAK < prev    next >
Text File  |  1996-09-27  |  12KB  |  422 lines

  1. /*---------------------------------------------------------------------------*\
  2.  *                                                                           *
  3.  *              Interactive Space Encyclopedia Install Program               *
  4.  *                                                                           *
  5.  *                                                                           *
  6.  *                        (c) Craig Williams 1996                            *
  7.  *                                                                           *
  8. \*---------------------------------------------------------------------------*/
  9.  
  10. // Constant declarations.
  11. #define PROGRAM_FOLDER_NAME     "Andromeda"
  12. #define APPBASE_PATH            "Spacewin\\"
  13. #define EXTRA_BLOCKSPACE        200000
  14.  
  15. #define COMPANY_NAME            "Andromeda"
  16. #define PRODUCT_NAME            "Interactive Space Encyclopedia"
  17. #define PRODUCT_VERSION         "2.00"
  18. #define PRODUCT_KEY             "SPACE2.00"
  19. #define DEINSTALL_KEY           "SPACEDeInstall"
  20.  
  21. declare
  22.  
  23. #include "sddialog.h"   // Include script dialog definitions.
  24.  
  25.     // Global variable declarations.
  26.   STRING  svFolder, svDir, szMsg, szFileSet, szTitle, svResult;
  27.     STRING  svTarget, szProgram, szTemp, svName, svCompany, szComponentList;
  28.   STRING  svUninstLogFile, szAppPath, szRegKey, szAppSharedDir, szWin32sVer;
  29.     
  30.   NUMBER  nResult, nType, nReturn, nvResult;
  31.   LIST    listInfo, listButtons, listDescrip;
  32.   NUMBER  nIcon, nFlag;
  33.  
  34.     // Function declarations.
  35.     prototype CheckRequirements();
  36.     prototype DetermineComponentInfo( STRING );
  37.     prototype EnoughSpace( STRING, STRING, NUMBER );
  38.     prototype PerformFileTransfer( STRING );
  39.     prototype SetupError( STRING );
  40.     prototype SetupScreen();
  41.  
  42. program
  43.  
  44. StartHere:
  45.     Disable( BACKGROUND );
  46.  
  47.     // Set installation info., which is required for registry entries.
  48.     InstallationInfo( COMPANY_NAME, PRODUCT_NAME, PRODUCT_VERSION, PRODUCT_KEY );
  49.  
  50.     // Set up the installation screen.
  51.     SetupScreen();
  52.     Enable( DIALOGCACHE );
  53.  
  54.  
  55.   // Create a Welcome dialog.
  56. WelcomeDlg:
  57.     Disable( BACKBUTTON );
  58.   Enable( NEXTBUTTON );
  59.   SdProductName( PRODUCT_NAME );
  60.   SdWelcome( "Welcome to the "+PRODUCT_NAME+" Install", "" );
  61.  
  62.   Enable( BACKBUTTON );
  63.  
  64.   // Test target system for proper configuration.
  65.     CheckRequirements();
  66.  
  67. GetType:
  68.   Disable( NEXTBUTTON );
  69.   listButtons = ListCreate( STRINGLIST );
  70.   listDescrip = ListCreate( STRINGLIST );
  71.  
  72.   ListAddString( listButtons, "@12001;1;255, 0, 255", AFTER );
  73.   ListAddString( listButtons, "@12003;1;255, 0, 255", AFTER );
  74.   ListAddString( listDescrip, "Typical\n"+
  75.                  "Recommended for most computers.  This is a full\n"+
  76.                  "installation of the Interactive Space Encyclopedia.", AFTER );
  77.   ListAddString( listDescrip, "Compact\n"+
  78.                  "Recommended for low specification computers. \n"+
  79.                  "This does not include full screen animations or the\n"+
  80.                  "Wordprocessor facility.", AFTER );
  81.  
  82.   nType = SdOptionsButtons( "Setup Option", "Select a setup type",
  83.                             listButtons, listDescrip );
  84.  
  85.   if ( nType = BACK ) then goto WelcomeDlg; endif;
  86.  
  87.  
  88.   Enable( NEXTBUTTON );
  89.  
  90.   ListDestroy( listButtons );
  91.   ListDestroy( listDescrip );
  92.  
  93.   svTarget        = TARGETDISK ^ APPBASE_PATH;
  94.     szAppSharedDir  = svTarget ^ "System";
  95.   szComponentList = "FileComponents";
  96.  
  97. GetTargetLocAndSelection:
  98.  
  99.   szMsg   = "Setup will install the %P in the following directory.\n\n"
  100.            +"To install to this directory, choose Next.\n"
  101.            +"To install to a different directory, choose Browse\n\n";
  102.  
  103.   nReturn = SdAskDestPath("Install To", szMsg, svTarget, 0 );
  104.     
  105.   if ( nReturn = BACK ) then goto GetType; endif;
  106.  
  107.  
  108.     szAppSharedDir  = svTarget ^ "System";
  109.  
  110.     // Perform space check of target drive.
  111.   if (EnoughSpace( svTarget, szComponentList, EXTRA_BLOCKSPACE ) = FALSE)
  112.     goto GetTargetLocAndSelection;
  113.  
  114.   GetProgramFolderInfo:
  115.  
  116.   svFolder = PROGRAM_FOLDER_NAME;
  117.     nResult = SdSelectFolder( "", "", svFolder );
  118.  
  119.   if ( nResult = BACK ) then goto GetType; endif;
  120.  
  121.     Disable( DIALOGCACHE );
  122.     szFileSet = "General";
  123.  
  124.     // Prepare InstallSHIELD to record deinstallation information.
  125.     DeinstallStart( svTarget, svUninstLogFile, DEINSTALL_KEY, 0 );
  126.     RegDBSetItem( REGDB_UNINSTALL_NAME, PRODUCT_NAME );
  127.  
  128.   Enable( STATUS );
  129.   Enable( INDVFILESTATUS );
  130. //  Enable( SELFREGISTERBATCH );
  131.  
  132.   TARGETDIR = svTarget;
  133.   SetStatusWindow(0, "Copying Files...." );
  134.   StatusUpdate(ON, 90);
  135.   CompressGet("DATA.Z", "*.*", COMP_NORMAL);
  136.  
  137.   // Hide Information Gauges
  138.   Disable( FEEDBACK_FULL );
  139.  
  140.   // Create program folder and icons.
  141.   CreateProgramIcons:
  142.  
  143.   SetStatusWindow(95, "Creating Program Group and Icons...." );
  144.  
  145.     AppCommand( PROGMAN, CMD_RESTORE );
  146.   CreateProgramFolder( svFolder );
  147.  
  148.   StrToLower( svTarget, svTarget );
  149.  
  150.   if (nType = 101) then
  151.      AddFolderIcon( svFolder, "Space",
  152.                 SRCDISK ^ "\\SPACEWIN\\EXE\\SPACEWIN.EXE " + svTarget,
  153.                 svTarget, "", 0, "", REPLACE );
  154.   else
  155.      AddFolderIcon( svFolder, "Space Low",
  156.                 SRCDISK ^ "\\SPACEWIN\\EXE\\SPACEWN1.EXE " + svTarget,
  157.                 svTarget, "", 0, "", REPLACE );
  158.   endif;
  159.  
  160.   AddFolderIcon( svFolder, "Install Video for Windows", SRCDISK ^
  161.                 "VFW\\SETUP.EXE", "", "", 0, "", REPLACE );
  162.  
  163.  
  164.   AddFolderIcon( svFolder, "Space ReadMe", "write.exe " + SRCDISK ^ "readme.wri",
  165.                  svTarget, "", 0, "", REPLACE );
  166.     Delay( 1 );
  167.  
  168.     szProgram = WINDIR ^ "UNINST16.EXE";
  169.     szProgram = szProgram + " -f" + svUninstLogFile;
  170.   AddFolderIcon( svFolder, "Uninstall Space", szProgram,
  171.                  WINDIR, "", 0, "", NULL );
  172.  
  173.   Delay( 1 );
  174.  
  175.   // Announce setup complete and offer to read README file.
  176.   CloseOfInstall:
  177.   SetStatusWindow( 100, "Installation complete." );
  178.  
  179.   if (AskYesNo( "Do you want to view the ReadMe file now?", YES) = YES) then
  180.     LaunchApp( "WRITE.EXE", SRCDISK ^ "readme.wri" );
  181.   endif;
  182.  
  183.   Delay( 1 );
  184.   Disable( STATUSDLG );
  185.  
  186.   if (nType = 101) then
  187.     szMsg = "Installation is complete. You may run the\n"+
  188.             "Interactive Space Encyclopedia by \n"+
  189.             "double-clicking the Space Icon.";
  190.   else
  191.     szMsg = "Installation is complete. You may run the\n"+
  192.             "Interactive Space Encyclopedia by \n"+
  193.             "double-clicking the Space Low Icon.";
  194.   endif;
  195.  
  196.   MessageBox( szMsg, INFORMATION );
  197.  
  198.   ShowProgramFolder( svFolder, SW_SHOW );
  199.  
  200.   exit;
  201.  
  202.  
  203. /*---------------------------------------------------------------------------*\
  204.  *
  205.  * Function:  SetupScreen
  206.  *
  207.  *  Purpose:  This function will set up the screen look.  This includes
  208.  *            colors, fonts, text to be displayed, etc.
  209.  *
  210.  *
  211.  *    Input:
  212.  *
  213.  *  Returns:
  214.  *
  215.  * Comments:
  216. \*---------------------------------------------------------------------------*/
  217.  
  218. function SetupScreen()
  219. string szBitmap;
  220. number nvDx, nvDy, nStatus, nDxBillboard, nDyBillboard;
  221. begin
  222.     GetExtents( nvDx, nvDy );
  223.  
  224.     Enable( FULLWINDOWMODE );
  225.  
  226.     Enable( INDVFILESTATUS );
  227.   Enable( BITMAP256COLORS );
  228.     Enable( DIALOGCACHE );
  229.  
  230.   SetColor( BACKGROUND, BK_BLUE );  // Gradient blue background.
  231.   SetColor( STATUSBAR, BLUE );
  232. //  SetTitle( "Interactive Space Encyclopedia", 24, WHITE);
  233.  
  234.   // Caption bar text.
  235.   SetTitle( "Interactive Space Encyclopedia Install", 0, BACKGROUNDCAPTION );
  236.   Enable( BACKGROUND );
  237.     Delay( 1 );
  238.  
  239.   // Show the bitmap - TITLE.BMP is in the _SETUP.LIB file
  240.   Enable( BITMAPFADE );
  241.   PlaceBitmap( SUPPORTDIR ^ "TITLE.BMP", 1, 10, 10, UPPER_LEFT );
  242.   Disable( BITMAPFADE );
  243.  
  244. end;
  245.  
  246.  
  247. /*---------------------------------------------------------------------------*\
  248.  *
  249.  * Function:  CheckRequirements
  250.  *
  251.  *  Purpose:  This function will check all minimum requirements for the
  252.  *            application being installed.  If any fail, then the user
  253.  *            is informed and the installation is terminated.
  254.  *
  255.  *
  256.  *    Input:
  257.  *
  258.  *  Returns:
  259.  *
  260.  * Comments:
  261. \*---------------------------------------------------------------------------*/
  262.  
  263. function CheckRequirements()
  264. number  nvDx, nvDy;
  265. number  nvVersion;
  266. string  svVersion;
  267. begin
  268.     // Check screen resolution.
  269.     GetExtents( nvDx, nvDy );
  270.     if (nvDy < 480) then
  271.        MessageBox( "This program requires VGA or better resolution.", WARNING );
  272.        exit;
  273.     endif;
  274. end;
  275.  
  276.  
  277. /*---------------------------------------------------------------------------*\
  278.  *
  279.  * Function:  PerformFileTransfer
  280.  *
  281.  *  Purpose:  This function will perform the file transfer and handle
  282.  *            any error that may occur during the file transfer.
  283.  *
  284.  *
  285.  *    Input:
  286.  *
  287.  *  Returns:
  288.  *
  289.  * Comments:
  290. \*---------------------------------------------------------------------------*/
  291.  
  292. function PerformFileTransfer( szFileSet )
  293. begin
  294.  
  295.     // Set up progress indicator and information gauge.
  296.     Disable( DIALOGCACHE );
  297.  
  298.   StatusUpdate( ON, 90 );
  299.   SetStatusWindow( 0, "Copying program files..." );
  300.  
  301.   TARGETDIR = WINSYSDIR ;
  302.   CompressGet( "data.z", "shared\\*.*", COMP_NORMAL );
  303.  
  304.   // Always include README files, located at the root of the
  305.   // DATA.Z library file.
  306.   TARGETDIR = svTarget;
  307.   CompressGet( "data.z", "*.*", COMP_NORMAL );
  308.  
  309.   // If program files are selected, then add them to file set.
  310.   SetStatusWindow( -1, "Copying program files..." );
  311.   TARGETDIR = svTarget;
  312.   CompressGet( "data.z", "voice\\*.*", COMP_NORMAL );
  313.  
  314. end;
  315.  
  316. /*---------------------------------------------------------------------------*\
  317.  *
  318.  * Function:  DetermineComponentInfo
  319.  *
  320.  *  Purpose:  This function will place all the separatly identifable
  321.  *            file components into a component list. It will also
  322.  *            set the size the files represent and will by default
  323.  *            enable each to be selected.
  324.  *
  325.  *
  326.  *    Input:
  327.  *
  328.  *  Returns:
  329.  *
  330.  * Comments:
  331. \*---------------------------------------------------------------------------*/
  332.  
  333. function DetermineComponentInfo( szFileList )
  334. number nvSize;
  335. string svSize;
  336. begin
  337.  
  338. /*  CompressInfo( "data.z", "voice\\*.*",
  339.               COMP_INFO_ORIGSIZE | INCLUDE_SUBDIR,
  340.               nvSize, svSize );
  341.     ComponentAddItem( szFileList, ITEM_INTROWAV, nvSize, TRUE );
  342.  
  343.   CompressInfo( "data.z", "shared\\*.*",
  344.               COMP_INFO_ORIGSIZE | INCLUDE_SUBDIR,
  345.           nvSize, svSize );
  346.     ComponentAddItem( szFileList, ITEM_THUMBNAILS, nvSize, TRUE );
  347. */
  348. end;
  349.  
  350. /*---------------------------------------------------------------------------*\
  351.  *
  352.  * Function:  EnoughSpace
  353.  *
  354.  *  Purpose:  This function will determine if enough space exists on
  355.  *            the target drive based on the selection in thge component
  356.  *            list.
  357.  *
  358.  *
  359.  *    Input:
  360.  *
  361.  *  Returns:
  362.  *
  363.  * Comments:
  364. \*---------------------------------------------------------------------------*/
  365.  
  366. function  EnoughSpace( svTarget, szComponentList, nExtraSpace )
  367. LIST    list;
  368. number  nTotal, nvSize, nFreeSpace, nResult;
  369. string  svComponent;
  370. begin
  371.  
  372.     // Get total size of all selected components.
  373.     list   = ListCreate( STRINGLIST );
  374.     nTotal = nExtraSpace;
  375.     ComponentListItems( szComponentList, list );
  376.  
  377.     nResult = ListGetFirstString( list, svComponent );
  378.  
  379.     while (nResult = 0)
  380.        ComponentGetItemSize( szComponentList, svComponent, nvSize );
  381.        if (ComponentIsItemSelected( szComponentList, svComponent )) then
  382.           nTotal = nTotal + nvSize;
  383.        endif;
  384.        nResult = ListGetNextString( list, svComponent );
  385.  
  386.     endwhile;
  387.  
  388.     ListDestroy( list );
  389.  
  390.     // Determine if target disk has enough space.
  391.     nFreeSpace = GetDiskSpace( svTarget );
  392.  
  393.     if (nFreeSpace < nTotal) then
  394.        szMsg = "There is not enough space available, %ld bytes, on the disk\n" +
  395.            "'" + svTarget + "' \n" +
  396.            "Please free up some space or change the target location\n" +
  397.            "to a different disk";
  398.        SprintfBox( WARNING, "Setup", szMsg, nTotal );
  399.        return FALSE;
  400.     endif;
  401.  
  402.     return TRUE; // Enough space.
  403. end;
  404.  
  405.  
  406. /*-----------------------------------------------------------------------
  407.  
  408.    Name    : SetupError
  409.  
  410.    Purpose : This function will construct messages and info for showing
  411.          an error message box.
  412.  
  413. -------------------------------------------------------------------------*/
  414. function SetupError( szMsg )
  415. begin
  416.     MessageBox( szMsg, SEVERE );
  417.     exit;
  418. end;
  419.  
  420.  
  421. #include "sddialog.rul"
  422.